#!/usr/bin/env node
import { program } from 'commander';
import chalk from 'chalk';
import { getLastCommit } from '../utils/git';
import { confirm } from '../utils/input';
import { runCmd } from '../utils/shell';

program
  .command('ac', { isDefault: true })
  .description('Add files without modify commit message')
  .action(run)
  .parse(process.argv);

async function run() {
  const message = await getLastCommit();
  const cmd = `git commit -m "${message}" --amend`;
  if (await confirm(`Are you sure to run cmd: ${chalk.yellow(cmd)}?`)) {
    await runCmd(cmd);
  }
}
